package apiserver

import (
	"gitee.com/youkelike/ziam/zsdk/sdk"
)

// 这个文件定义全局共用的客户端对象

// 必须要有对 sdk.Client 的这层封装，
// sdk.Client 专注于底层通信，
// 在 Client 上添加各种接口方法用于外部调用
type Client struct {
	sdk.Client
}

func NewClientWithJwt(jwt string) (client *Client, err error) {
	client = &Client{}
	config := sdk.NewConfig().
		SetBearerToken(jwt).
		SetEndpoint("127.0.0.1:8080").
		SetInsecure(false).
		SetSecureHost("127.0.0.1:8443").
		SetServerName("api.ziam.com").
		SetCAFile(`D:\goproject\ziam\config/cert/ca.pem`).
		SetCertFile(`D:\goproject\ziam\config/cert/ziam-apiserver.pem`).
		SetKeyFile(`D:\goproject\ziam\config/cert/ziam-apiserver-key.pem`)
	client.Init().SetConfig(config)
	return
}

// Bool is a helper routine that allocates a new bool value
// to store v and returns a pointer to it.
func Bool(v bool) *bool { return &v }

// Int is a helper routine that allocates a new int value
// to store v and returns a pointer to it.
func Int(v int) *int { return &v }

// Int64 is a helper routine that allocates a new int64 value
// to store v and returns a pointer to it.
func Int64(v int64) *int64 { return &v }

// String is a helper routine that allocates a new string value
// to store v and returns a pointer to it.
func String(v string) *string { return &v }
